<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="./js/react.development.js "></script>
    <script src="./js/react-dom.development.js "></script>
    <script src="./js/babel.min.js "></script>
    <script type="text/babel">
      const arr = [
        { id: 1, name: 'hj', age: '38' },
        { id: 2, name: 'lt', age: '58' },
        // { id: 3, name: 'lw', age: '88' },
      ]
      // 根据arr数组,得到一个新数组,新数组中是一个一个的li标签
      const newArr = arr.map((item) => {
        return (
          // 注意: 当我们列表渲染的时候,应该在一段jsx标签的最外层的标签上写一个key属性,值不能重复. react用来在内部执行时提高性能
          <li key={item.id}>
            <h1>{item.name}</h1>
            <p>{item.age}</p>
          </li>
        )
      })
      // console.log(newArr)

      const ul = <ul>{newArr}</ul>
      ReactDOM.render(ul, document.getElementById('root'))
    </script>
  </body>
</html>
